<template>
  <div class="page-container">
    <SearchPanel @change="handleSearchPanelChange">
      <el-form
        ref="queryForm"
        class="query-more-form"
        size="mini"
        label-width="100px"
        :model="query"
      >
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="名称">
              <el-input
                v-model="query.unitName"
                class="search-ipt"
                placeholder="请输入名称"
                maxlength="255"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="证件号码">
              <el-input
                v-model="query.businessCard"
                class="search-ipt"
                placeholder="请输入证件号码"
                maxlength="255"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="主体类型">
              <el-select
                class="w-100"
                v-model="query.type"
                placeholder="请选择主体类型"
                clearable
                ><el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" class="btn-col">
            <el-button size="mini" class="search-btn">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
    </SearchPanel>
    <div class="table-container">
      <div class="table-tools-panel table-flex-row">
        <div>
          <el-button class="flush-btn blue" icon="el-icon-plus" @click="addCust"
            >新增</el-button
          >
        <el-button class="flush-btn yellow" size="mini" icon="el-icon-refresh" 
          @click="refresh"
          >刷新</el-button
        >
        </div>
        <div>
          <el-button
            class="tools-btn"
            size="mini"
            icon="el-icon-set-up"
          ></el-button>
          <el-button
            class="tools-btn"
            size="mini"
            icon="el-icon-share"
          ></el-button>
          <el-button
            class="tools-btn"
            size="mini"
            icon="el-icon-printer"
          ></el-button>
        </div>
      </div>
      <div class="table-list-panel">
        <el-table
          v-loading="tableLoading"
          border
          size="small"
          :data="tableData"
          :height="isShow ? 'calc(100vh - 410px)' : 'calc(100vh - 335px)'"
          style="width: 100%"
        >
          <el-table-column type="selection" width="45" />
          <el-table-column
            prop="key"
            width="60"
            label="ID"
            show-overflow-tooltip
          />
          <el-table-column
            prop="publisherTime"
            label="发布时间"
            show-overflow-tooltip
            sortable
          />
          <el-table-column
            prop="publisher"
            label="发布人"
            show-overflow-tooltip
          />
          <el-table-column
            prop="title"
            label="标题"
            show-overflow-tooltip
          />
          <el-table-column
            prop="content"
            label="内容"
            show-overflow-tooltip
          />
          <el-table-column
            prop="enclosure"
            label="附件"
            show-overflow-tooltip
          />
        </el-table>
      </div>
      <div class="pagination-panel">
        <Pagination
          :total="query.total"
          :page.sync="query.pageNum"
          :limit.sync="query.pageSize"
          @pagination="initData"
        />
      </div>
    </div>
  </div>
</template>

<script>
import SearchPanel from "@/components/SearchPanel";
import Pagination from "@/components/Pagination";
import { getList } from "@/api/system/lawsRegulations";
export default {
  name: "CaseDealDispatch",
  components: {
    SearchPanel,
    Pagination,
  },
  data() {
    return {
      query: {
        total: 1,
        pageNum: 1,
        pageSize: 10,
        type: 3,
        // type	类型（1法律法规、2政策法规、3通知公告)
      },
      options: [
        {
          value: "1",
          label: "法人",
        },
        {
          value: "2",
          label: "个人",
        },
      ],
      tableLoading: false,
      tableData: [],
      isShow: true,
    };
  },
  created() {
    this.initData();
    // getList().then((response) => {
    //   this.department = response.rows;
    // });
  },
  methods: {
    handleSearchPanelChange(flag) {
      this.isShow = flag;
    },
    initData() {
      this.select();
    },
    select() {
      this.tableLoading = true;
      getList(this.query)
        .then((result) => {
          this.tableLoading = false;
          this.query.total = result.total;
          this.tableData = result.rows;
        })
        .catch(() => {
          this.tableLoading = false;
        });
    },
    // 刷新页面
    refresh() {
      this.query = {
        total: 1,
        pageNum: 1,
        pageSize: 10,
        type: 1,
        name: "",
      };
      this.select();
    },
    // 新增
    addCust() {
      this.visible = true;
      this.dialogType = "add";
      this.obj = {};
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
